package com.iotimc.attendancesystem.datautil;

import android.graphics.Bitmap;
import android.graphics.Rect;

public class ImageData
{
	private static ImageData imageData = null;
	
	private static Bitmap colorImage = null;
	private static byte[] processImage = null;
	private static byte[] mTemplate = null;
	private static int mWidth = 0;
	private static int mHeight = 0;
	private static Rect mRect = new Rect();
	
	
    private ImageData()
    {
    	
    }
    
    private static void byteArrayCopy(byte[] src, byte[] dest, int len)
    {
    	int i;
    	
    	for (i=0; i<len; i++)
    	{
    		src[i] = dest[i];
    	}
    }
    
    
    public static void setData(Bitmap color, byte[] process, byte[] template, int width, int height, Rect rect)
    {
    	colorImage = color;
    	
    	processImage = new byte[process.length];
    	byteArrayCopy(processImage, process, process.length);
    	
    	mTemplate = new byte[template.length];
    	byteArrayCopy(mTemplate, template, template.length);
    	
    	
    	mWidth = width;
    	mHeight = height;
    	
    	mRect.top = rect.top;
    	mRect.bottom = rect.bottom;
    	mRect.left = rect.left;
    	mRect.right = rect.right;
    	
    	mRect.top = (rect.top - 50 > 0) ? (rect.top - 50) : 0;
    	mRect.bottom = (mRect.bottom - mRect.top > height/2) ? (mRect.bottom ) : (mRect.top + height/2);
    	
    	if (mRect.bottom >= height)
    	{
    		mRect.bottom = height - 1;
    	}
    	
    	mRect.left = (rect.left - 50 > 0) ? (rect.left - 50) : 0;
    	mRect.right = (mRect.right + 50 > width) ? (width - 1 ) : (mRect.right + 50 );
    	
    }
    
    public static Bitmap getColorImage()
    {
    	return colorImage;
    }
    
    public static byte[] getProcessImage()
    {
    	return processImage;
    }
    
    public static byte[] getTemplate()
    {
    	return mTemplate;
    }
    
    public static int getWidth()
    {
    	return mWidth;
    }
    
    
    public static int getHeight()
    {
    	return mHeight;
    }
    
    public static Rect getRect()
    {
    	return mRect;
    }
    
   
}
